package cnpm02.j2ee.group3.model;

import static javax.persistence.CascadeType.MERGE;
import static javax.persistence.CascadeType.PERSIST;

import java.util.Date;

import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.validator.NotNull;

@Entity
@Table(name = "SOLDTICKET")
@AttributeOverride(name = "id", column = @Column(name = "SoldTicketId"))
public class SoldTicket extends AbstractEntity {
	private static final long serialVersionUID = 1L;

	@NotNull
	@ManyToOne(cascade = {PERSIST, MERGE})
	@JoinColumn(name = "CustomerId", nullable = false)
	private Person customer;
	
	@NotNull
	@ManyToOne(cascade = {PERSIST, MERGE})
	@JoinColumn(name = "TicketId", nullable = false)
	private Ticket ticket;
	
	@NotNull
	@Column(name = "Quantity", nullable = false)
	private int quantity;
	
	@NotNull
	@Column(name = "Price", nullable = false)
	private long price;
	
	@NotNull
	@Column(name = "SoldDate", nullable = true)
	@Temporal(TemporalType.TIMESTAMP)
	private Date soldDate;
	
	@NotNull
	@Enumerated(EnumType.STRING)
	@Column(name = "Status", nullable = false, length = 10)
	private SoldTicketStatus status;
	
	public void setCustomer(Person customer) {
		this.customer = customer;
	}
	
	public Person getCustomer() {
		return customer;
	}

	public void setTicket(Ticket ticket) {
		this.ticket = ticket;
	}

	public Ticket getTicket() {
		return ticket;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public int getQuantity() {
		return quantity;
	}

	public void setPrice(long price) {
		this.price = price;
	}

	public long getPrice() {
		return price;
	}

	public void setSoldDate(Date soldDate) {
		this.soldDate = soldDate;
	}

	public Date getSoldDate() {
		return soldDate;
	}

	public void setStatus(SoldTicketStatus status) {
		this.status = status;
	}

	public SoldTicketStatus getStatus() {
		return status;
	}
}
